#pragma once
#include "..\tracedll\message.h"
#include <unordered_map>


using namespace std;
using namespace std::tr1;

class TraceCollection
{
public:
	typedef unordered_map<void*, LogMessage> MessageMap;
	typedef unordered_map<LogMessage::Stackinfo, vector<LogMessage>, StackInfoHash > GroupedMessageMap;
	TraceCollection(void);
	~TraceCollection(void);
	
	//Add trace message to collction. 
	// NOTE:It's not thread safe. Need lock if it's possible accessed by multi-thread
	void AddMessage(const LogMessage& message);

	//Get messages of memory allocation log that are still not freed
	const MessageMap& GetMessageMap() const;

	//Get remaining memory allcation messages grouped by call stack
	const GroupedMessageMap GetGroupedMessageMap(); 
private:
	MessageMap m_memtraceMap;
	GroupedMessageMap m_groupedMessageMap;
};

